﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Net;
using System.Net.Sockets;

namespace CSharpServer
{
	class Server
	{
		static void Main(string[] args)
		{
			Console.WriteLine("Server is running ...");
			IPAddress ip = IPAddress.Parse("127.0.0.1");
			int port = 8500;

			TcpListener listener = new TcpListener(ip, port);
			listener.Start();
			Console.WriteLine("Start Listening ...");


			while (true)
			{
				//TcpClient remoteClient = listener.AcceptTcpClient();

				//Console.WriteLine("Client Connected! {0} <-- {1}",
				//                  remoteClient.Client.LocalEndPoint,
				//                  remoteClient.Client.RemoteEndPoint);

				//NetworkStream stream = remoteClient.GetStream();
				//byte[] buffer = new byte[BufferSize];

				//int byteRead = stream.Read(buffer, 0, BufferSize);

				//Console.WriteLine("Reading data, {0} bytes...", byteRead);

				//// 获得请求的字符串
				//string msg = Encoding.Unicode.GetString(buffer, 0, byteRead);
				//Console.WriteLine("Received: {0}", msg);


				TcpClient client = listener.AcceptTcpClient();
				RemoteClient wapper = new RemoteClient(client);
			}

			//ConsoleKey key;
			//do 
			//{
			//    key = Console.ReadKey(true).Key;
			//} while (key != ConsoleKey.Q);
		}
	}
}
